package com.duyan.learning;

public class ShellSort {
	InsertionSort insertionSort = new InsertionSort();

	public void sort(int a[], int k) {
		while (k >= 1) {
			int segment = 0;
			while (segment <= k) {
				int current = segment + k;
				while (current < a.length) {
					int temp = a[current];
					int walker = current - k;
					while ((walker >= 0) && (temp < a[walker])) {
						a[walker + k] = a[walker];
						walker = walker - k;
					}
					a[walker + k] = temp;
					current = current + k;
				}
				segment = segment + 1;
			}
			k = k-1;
			//System.out.println(k);
		}

	}
}
